// debounce
function debounce(fn, time) {
    let timer = null;
    return function (...args) {
        clearTimeout(timer)
        timer = setTimeout(() => {
            fn.apply(this, args)
        }, time)

    }

}

// throtte
function throtte(fn, time) {
    let cDate = 0;
    return function (...args) {
        let curDate = Date.now();
        if (curDate - cDate > time) {
            fn.apply(this, args)
            cDate = Date.now()
        }
    }
}

function throtte(fn,time){
    let timer = null;
    return function(...args){
        if(!timer){
            timer = setTimeout(()=>{
                tiemr = null;
                fn.apply(this,args)
            },time)
        }
    }
}
